home *** CD-ROM | disk | FTP | other *** search
/ Aminet 48 / Aminet 48 (2002)(GTI - Schatztruhe)[!][Apr 2002].iso / Aminet / text / edit / vim60rt.lha / Vim / vim60 / syntax / dtd.vim < prev    next >
Encoding:
Text File  |  2001-09-02  |  5.3 KB  |  177 lines

  1. " Vim syntax file
  2. " Language:    DTD (Document Type Definition for XML)
  3. " Maintainer:    Johannes Zellner <johannes@zellner.org>
  4. "        Author and previous maintainer:
  5. "        Daniel Amyot <damyot@site.uottawa.ca>
  6. " Last Change:    Wed, 06 Jun 2001 14:07:20 +0200
  7. " Filenames:    *.dtd
  8. " URL:        http://www.zellner.org/vim/syntax/dtd.vim
  9. "
  10. " REFERENCES:
  11. "   http://www.w3.org/TR/html40/
  12. "   http://www.w3.org/TR/NOTE-html-970421
  13. "
  14. " TODO:
  15. "   - improve synchronizing.
  16.  
  17. if version < 600
  18.     syntax clear
  19.     let __dtd_cpo_save__ = &cpo
  20.     set cpo&
  21. else
  22.     if exists("b:current_syntax")
  23.     finish
  24.     endif
  25.     let s:dtd_cpo_save = &cpo
  26.     set cpo&vim
  27. endif
  28.  
  29. if !exists("dtd_ignore_case")
  30.     " I prefer having the case takes into consideration.
  31.     syn case match
  32. else
  33.     syn case ignore
  34. endif
  35.  
  36.  
  37. " the following line makes the opening <! and
  38. " closing > highlighted using 'dtdFunction'.
  39. syn region dtdTag matchgroup=dtdFunction
  40.     \ start=+<!+ end=+>+ matchgroup=NONE
  41.     \ contains=dtdTag,dtdTagName,dtdError,dtdComment,dtdString,dtdAttrType,dtdAttrDef,dtdEnum,dtdParamEntityInst,dtdParamEntityDecl,dtdCard
  42.  
  43. if !exists("dtd_no_tag_errors")
  44.     " mark everything as an error which starts with a <!
  45.     " and is not overridden later. If this is annoying,
  46.     " it can be switched off by setting the variable
  47.     " dtd_no_tag_errors.
  48.     syn region dtdError contained start=+<!+lc=2 end=+>+
  49. endif
  50.  
  51. " if this is a html like comment hightlight also
  52. " the opening <! and the closing > as Comment.
  53. syn region dtdComment        start=+<![ \t]*--+ end=+-->+ contains=dtdTodo
  54.  
  55.  
  56. " proper DTD comment
  57. syn region dtdComment contained start=+--+ end=+--+ contains=dtdTodo
  58.  
  59.  
  60. " Start tags (keywords). This is contained in dtdFunction.
  61. " Note that everything not contained here will be marked
  62. " as error.
  63. syn match dtdTagName contained +<!\(ATTLIST\|DOCTYPE\|ELEMENT\|ENTITY\|NOTATION\|SHORTREF\|USEMAP\|\[\)+lc=2,hs=s+2
  64.  
  65.  
  66. " wildcards and operators
  67. syn match  dtdCard contained "|"
  68. syn match  dtdCard contained ","
  69. " evenutally overridden by dtdEntity
  70. syn match  dtdCard contained "&"
  71. syn match  dtdCard contained "?"
  72. syn match  dtdCard contained "\*"
  73. syn match  dtdCard contained "+"
  74.  
  75. " ...and finally, special cases.
  76. syn match  dtdCard      "ANY"
  77. syn match  dtdCard      "EMPTY"
  78.  
  79. if !exists("dtd_no_param_entities")
  80.  
  81.     " highlight parameter entity declarations
  82.     " and instances. Note that the closing `;'
  83.     " is optional.
  84.  
  85.     " instances
  86.     syn region dtdParamEntityInst oneline matchgroup=dtdParamEntityPunct
  87.     \ start="%[-_a-zA-Z0-9.]\+"he=s+1,rs=s+1
  88.     \ skip=+[-_a-zA-Z0-9.]+
  89.     \ end=";\|\>"
  90.     \ matchgroup=NONE contains=dtdParamEntityPunct
  91.     syn match  dtdParamEntityPunct contained "\."
  92.  
  93.     " declarations
  94.     " syn region dtdParamEntityDecl oneline matchgroup=dtdParamEntityDPunct start=+<!ENTITY % +lc=8 skip=+[-_a-zA-Z0-9.]+ matchgroup=NONE end="\>" contains=dtdParamEntityDPunct
  95.     syn match dtdParamEntityDecl +<!ENTITY % [-_a-zA-Z0-9.]*+lc=8 contains=dtdParamEntityDPunct
  96.     syn match  dtdParamEntityDPunct contained "%\|\."
  97.  
  98. endif
  99.  
  100. " &entities; compare with xml
  101. syn match   dtdEntity              "&[^; \t]*;" contains=dtdEntityPunct
  102. syn match   dtdEntityPunct  contained "[&.;]"
  103.  
  104. " Strings are between quotes
  105. syn region dtdString    start=+"+ skip=+\\\\\|\\"+  end=+"+ contains=dtdAttrDef,dtdAttrType,dtdEnum,dtdParamEntityInst,dtdEntity,dtdCard
  106. syn region dtdString    start=+'+ skip=+\\\\\|\\'+  end=+'+ contains=dtdAttrDef,dtdAttrType,dtdEnum,dtdParamEntityInst,dtdEntity,dtdCard
  107.  
  108. " Enumeration of elements or data between parenthesis
  109. syn region dtdEnum matchgroup=dtdType start="(" end=")" matchgroup=NONE contains=dtdEnum,dtdParamEntityInst,dtdCard
  110.  
  111. "Attribute types
  112. syn keyword dtdAttrType NMTOKEN  ENTITIES  NMTOKENS  ID  CDATA
  113. syn keyword dtdAttrType IDREF  IDREFS
  114. " ENTITY has to treated special for not overriding <!ENTITY
  115. syn match   dtdAttrType +[^!]\<ENTITY+
  116.  
  117. "Attribute Definitions
  118. syn match  dtdAttrDef   "#REQUIRED"
  119. syn match  dtdAttrDef   "#IMPLIED"
  120. syn match  dtdAttrDef   "#FIXED"
  121.  
  122. syn case match
  123. " define some common keywords to mark TODO
  124. " and important sections inside comments.
  125. syn keyword dtdTodo contained TODO FIXME XXX
  126.  
  127. syn sync lines=250
  128.  
  129. " Define the default highlighting.
  130. " For version 5.7 and earlier: only when not done already
  131. " For version 5.8 and later: only when an item doesn't have highlighting yet
  132. if version >= 508 || !exists("did_dtd_syn_inits")
  133.     if version < 508
  134.     let did_dtd_syn_inits = 1
  135.     command -nargs=+ HiLink hi link <args>
  136.     else
  137.     command -nargs=+ HiLink hi def link <args>
  138.     endif
  139.  
  140.     " The default highlighting.
  141.     HiLink dtdFunction        Function
  142.     HiLink dtdTag        Normal
  143.     HiLink dtdType        Type
  144.     HiLink dtdAttrType        dtdType
  145.     HiLink dtdAttrDef        dtdType
  146.     HiLink dtdConstant        Constant
  147.     HiLink dtdString        dtdConstant
  148.     HiLink dtdEnum        dtdConstant
  149.     HiLink dtdCard        dtdFunction
  150.  
  151.     HiLink dtdEntity        Statement
  152.     HiLink dtdEntityPunct    dtdType
  153.     HiLink dtdParamEntityInst    dtdConstant
  154.     HiLink dtdParamEntityPunct    dtdType
  155.     HiLink dtdParamEntityDecl    dtdType
  156.     HiLink dtdParamEntityDPunct dtdComment
  157.  
  158.     HiLink dtdComment        Comment
  159.     HiLink dtdTagName        Statement
  160.     HiLink dtdError        Error
  161.     HiLink dtdTodo        Todo
  162.  
  163.     delcommand HiLink
  164. endif
  165.  
  166. if version < 600
  167.     let &cpo = __dtd_cpo_save__
  168.     unlet __dtd_cpo_save__
  169. else
  170.     let &cpo = s:dtd_cpo_save
  171.     unlet s:dtd_cpo_save
  172. endif
  173.  
  174. let b:current_syntax = "dtd"
  175.  
  176. " vim: ts=8
  177.